<extend name="layout/main" />

<block name="HEADER">
	<style type="text/css">
		#grid .layui-table-view .layui-table td .layui-table-cell{
			height: 45px;
		    line-height: 45px;
		}
		#grid .file-img {
		    height: 100%;
		    background-position: left;
		    background-size: 100% 85%;
		    background-repeat: no-repeat;
		    cursor: pointer;
		}
	</style>
</block>

<block name="CONTENT">
	<control:grid id="grid"/>
	<textarea  id="biao1" style="display: none;"></textarea>
</block>

<block name="FOOTER">
	<script type="text/javascript">
		var page = (function(ns){
     
		    //页面初始化
		    ns.init=function(){

		    }
		    
		    //新增
		    ns.add=function(){
		    	var filter = {
		            url: $.getModule('news'),
		            oid:"",
		            mode:1
		        }
		        $.openIframe(filter, "新增会员卡",['700px', '550px']);
		    }
		    
		    //编辑
		    ns.edit=function(){
		    	var selectedRow = grid.getSelectedRows()[0];
		        var filter = {
		            url: $.getModule('news'),
		            oid: selectedRow.id ,
		            mode:3
		        }
		        $.openIframe(filter, "会员卡详情",['700px', '550px']);
		    }
		    
		    //明细
		    ns.detail =function(){
		    	var selectedRow = grid.getSelectedRows()[0];
		        var filter = {
		            url: 'system/member/index/edit',
		            oid: selectedRow.bind_uid ,
		            mode:3
		        }
		        $.openIframe(filter, "会员详情",['800px', '92%']);
		    }  
		    
		    //复制密码
		    ns.copy =function(password){
		    	var dom = $("#biao1").html(password).show().select(); // 选择对象
				document.execCommand("Copy"); // 执行浏览器复制命令
				dom.hide();
		    	$.toast(1,'复制成功！');
		    }
		    
		    //删除
		    ns.del =function(){
		    	if( !grid.isSelected() ){
		    		return false;
		    	}
		    	if( grid.getSelectedColumnValue('status').indexOf("1") != -1 ){
		    		$.alert(0,"选中数据存在已被领取会员卡，不能删除！");
		    		return false;
		    	}
		    	grid.deleteSelectRow(true)
		    }
		    
		    //下拉移动  type: 1 = 上移 ,  type: 2 = 下移
		    ns.move = function(type){
		    	grid.adjustSort(type,"sort_no");
		    }
		    
		    return ns;
		}({}));
		
		
		$(function(){ page.init();  });

	</script>
</block>